import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:getwidget/components/toggle/gf_toggle.dart';
import 'package:getwidget/types/gf_toggle_type.dart';

import '../controllers/gftoggle_controller.dart';

class GftoggleView extends GetView<GftoggleController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('切换'),
        centerTitle: true,
      ),
      body: Container(
        margin: EdgeInsets.all(10),
        child: ListView(
          children: [
            GFToggle(
              onChanged: (val) {
                _snackbar(val);
              },
              value: true,
            ),

            Wrap(
              alignment: WrapAlignment.spaceBetween,
              children: [
                GFToggle(
                  onChanged: (val) {
                    _snackbar(val);
                  },
                  value: true,
                  type: GFToggleType.ios,
                ),
                GFToggle(
                  onChanged: (val) {
                    _snackbar(val);
                  },
                  enabledTrackColor: Colors.blue,
                  value: true,
                  type: GFToggleType.ios,
                ),
                GFToggle(
                  onChanged: (val) {
                    _snackbar(val);
                  },
                  enabledTrackColor: Colors.deepPurple,
                  value: true,
                  type: GFToggleType.ios,
                ),
              ],
            ),

            

            GFToggle(
              onChanged: (val) {
                _snackbar(val);
              },
              value: true,
              type: GFToggleType.square,
            ),
          ],
        ),
      ),
    );
  }

  void _snackbar(val) {
    Get.snackbar(
      '提示', 
      '结果：'+val.toString(),
      snackPosition: SnackPosition.BOTTOM,
      // icon: Icon(Icons.info_outline, size: 60, color: Colors.blue),
      backgroundColor: Colors.blue.shade100,
      showProgressIndicator: true
    );
  }
}
